package com.hisicom.scqxspxcjc.base.bean;

import cn.hutool.core.date.DateUtil;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.util.Date;

/**
 * @author zhonggls
 * @date 2020/4/22 10:27
 * @Explain
 */
@MappedSuperclass
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "id" , columnDefinition = "char(32)", unique = true, nullable = false,length = 32)
    public String id;
    //    @CreatedDate
//    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "create_time", unique = false, nullable = true, insertable = true, updatable = true)
    public Long createTime = System.currentTimeMillis();//创建时间

//    @Override
//    public String toString() {
//        return ReflectionToStringBuilder.toString(this);
//    }

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getDateCreateTime() {
        return this.createTime != null ? new Date(this.createTime) : null;
    }
    public String getStrCreateTime() {
        return this.createTime != null ? DateUtil.formatDateTime(new Date(this.createTime)) : null;
    }

    public Long getCreateTime() {
        return this.createTime;
    }
}

